package com.xlh.enums.course;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * 模版类型枚举
 * <p>
 * Created by lx on 2019/1/28.
 */
@Getter
@AllArgsConstructor
public enum TemplateTypeEnum {

    COURSE_REPORT(1, "实验课报告模板"),
    TEST_REPORT(2, "实验考试报告模板"),
    EVALUATION(3, "评语模板");

    private Integer code;

    private String message;

    public static TemplateTypeEnum getByCode(Integer code) {
        for (TemplateTypeEnum templateTypeEnum : TemplateTypeEnum.values()) {
            if (Objects.equals(templateTypeEnum.getCode(), code)) {
                return templateTypeEnum;
            }
        }
        return null;
    }

    public static String getMessageByCode(Integer code) {
        TemplateTypeEnum templateTypeEnum = getByCode(code);
        return templateTypeEnum == null ? null : templateTypeEnum.getMessage();
    }

}
